//
//  Qb_LoginViewController.m
//  Cd_Qb
//
//  Created by mac on 2018/3/8.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "Qb_LoginViewController.h"
#import "Qb_MainTabBarController.h"
//#import "Qb_ColletViewController.h"

@interface Qb_LoginViewController ()<UITextFieldDelegate>
/*
 *约束
 */
//登陆标签
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_LoginLabelTop;
//用户头像
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_UserImgTop;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_UserImgH;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_UserImgW;
//中间帐号密码框
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_CenterViewTop;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_CenterViewLeft;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_CenterViewRight;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_CenterViewH;
//帐号
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_CenterOneViewImgTop;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_CenterOneViewImgLeft;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_CenterOneViewImgH;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_CenterOneViewImgW;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_CenterOneViewFieldLeft;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_CenterOneViewFieldRight;
//密码
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_CenterTwoViewImgTop;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_CenterTwoViewImgLeft;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_CenterTwoViewImgH;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_CenterTwoViewImgW;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_CenterTwoViewFieldLeft;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_CenterTwoViewFieldRight;
//登陆按钮
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_LoginBtnTop;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_LoginBtnH;
//忘记注册
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_FootOneViewTop;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_FootOneViewLeft;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_FootOneViewRight;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_FootOneViewH;
//三方登陆
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_FootTwoViewTop;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_FootTwoViewH;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Qb_FootTwoViewW;

@property (weak, nonatomic) IBOutlet UITextField *NameField;
@property (weak, nonatomic) IBOutlet UITextField *PassField;


@end

@implementation Qb_LoginViewController


-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self AdaptationApp];
    self.NameField.delegate = self;
    self.PassField.delegate = self;
}

#pragma mark -- Action
//登陆
- (IBAction)OnLoginBtnClick:(id)sender {
    self.view.window.rootViewController = [[Qb_MainTabBarController alloc] init];
}
//忘记密码
- (IBAction)OnForgetBtnClick:(id)sender {
    [self.navigationController pushViewController:Storyboard(@"Main", @"Qb_LoginForgetViewController") animated:YES];
    
}
//注册
- (IBAction)OnRegisterBtnClick:(id)sender {
     [self.navigationController pushViewController:Storyboard(@"Main", @"Qb_LoginRegisterViewController") animated:YES];
}

//三方登陆
- (IBAction)OnThreeBtnClick:(UIButton*)sender {
    if (sender.tag == 1001) {
        NSLog(@"QQ三方登陆");
    }
    if (sender.tag == 1002) {
        NSLog(@"WC三方登陆");
    }
    if (sender.tag == 1003) {
        NSLog(@"XL三方登陆");
    }
}

#pragma mark -- UITextFieldDelegate

- ( void )textFieldDidBeginEditing:( UITextField*)textField{
    if ([textField isEqual:self.NameField]) {
        if ([self.NameField.text isEqualToString:@"请输入帐号"]) {
            self.NameField.text = @"";
        }
    }else{
        if ([self.PassField.text isEqualToString:@"请输入密码"]) {
            self.PassField.text = @"";
        }
    }
}

- ( void )textFieldDidEndEditing:( UITextField *)textField{
    if ([textField isEqual:self.NameField]) {
        if (self.NameField.text.length == 0) {
             self.NameField.text = @"请输入帐号";
        }
    }else{
        if (self.PassField.text.length == 0) {
            self.PassField.text = @"请输入密码";
        }
    }
}


@end
